<template>
    <div>
        <van-nav-bar title="智慧商城" />
        <van-search @click="$router.push('/search')" shape="round" background="#f1f1f2" placeholder="搜索你要找的商品" />
        <van-swipe :autoplay="3000">
            <van-swipe-item v-for="(image, index) in images" :key="index">
                <img :src="image.imgUrl" />
            </van-swipe-item>
        </van-swipe>

        <van-notice-bar scrollable left-icon="volume-o" :text="ShopNotices" />

        <van-grid :column-num="5" :border="false">
            <van-grid-item :icon="item.imgUrl" :text="item.text" v-for="(item, index) in Navigation" :key="index" />
        </van-grid>
        <img :src="item.imgUrl" v-for="item in imageList" :key="item.id" style="width: 100%;" />
        <div class="like">—— 猜你喜欢 ——</div>

        <van-card  v-for="item in Product" :key="item.goods_id"
         :price="item.goods_price_max"
         :desc="'已售'+item.goods_sales+'件'"
          :title="item.goods_name"
          :thumb="item.goods_image" />
    </div>
</template>

<script>
import { homepage } from '@/api/actilce'
export default {
  name: 'HomepageView',
  data () {
    return {
      images: [],
      ShopNotices: '',
      Navigation: [],
      imageList: '',
      Product: []
    }
  },
  async created () {
    const res = await homepage()
    console.log(res)
    console.log(res.data.pageData.items[2].params.text)
    // 轮播图
    this.images = res.data.pageData.items[1].data
    // 店铺公告
    this.ShopNotices = res.data.pageData.items[2].params.text
    // 导航组
    this.Navigation = res.data.pageData.items[3].data
    this.imageList = res.data.pageData.items[4].data
    this.Product = res.data.pageData.items[6].data
  }
}
</script>

<style lang="less" scoped>

.van-nav-bar {
    background: #c21401;

}

/deep/ .van-nav-bar__title {
    color: #fff;
}

/deep/ .van-search__content {
    background: #fff;
}

/deep/.van-swipe__track {
    height: 200px;
}

/deep/.van-swipe-item img {
    width: 100%;
    height: 200px;
}

/deep/ .van-notice-bar {
    background: #525252;
    color: #fff;
    height: 35px;
}

  // item
  .like {
    height: 7.7867vw;
    padding: 1.3333vw 0;
    background-color: #fff;
    font-size: 3.7333vw;
    text-align: center;
    line-height: 6.24vw;
    border-bottom: 1px solid #f6f6f6;
  }
 /deep/ .van-card:nth-last-child(1) {
    margin-bottom: 50px;
 }
</style>
